import os
import os.path as osp
import csv
import pandas as pd

csv_path = "workspaces/hjh9_data/dianjiao_dataset/dataset_0615.csv"
save_path = "dataset.csv"

replace_info = ['workspaces/hjh9_data/dianjiao_dataset/dataset_0615', '/dfs/data/aisz/panhui9/total/incremental/patch']

with open(save_path, 'w', newline='') as csvfile:
    pd_data = pd.read_csv(csv_path)

    spamwriter = csv.writer(csvfile, delimiter=',',
                        quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(['img_pth','img_name','source'] ) #

    for index, row in pd_data.iterrows():
        p = row['img_pth'].replace(replace_info[0], replace_info[1])
        source = row["source"]
        img_name = row["img_name"]
        spamwriter.writerow([p, img_name, source])
csvfile.close()
